<html lang="zh-CN">
	<head>
	<meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
	<style type="text/css">
		body{
			font-size:12px;
		}
		.container{
			display: flex; /* 使用弹性盒模型 */
		}
		ul{
			padding:0px;
			margin:0px;
		}
		ul li{		
			list-style-type: none;
		}
		.deep{
			color:#000000;
			background-color: #FFFF99;
		}
		.answer{
		}
		.question{
		}
		
	</style>	
		<title>java base </title>
		<script src="jquery-3.7.1.min.js"></script>
	</head>
	<body>
	<h1>java base </h1>
	<ul id="list">
		<li>
			<p>
				<div class="container">
					<div id="question_0" class="question">创建线程的有哪些方式</div>
					<div>
						<button type="button" id="question_btn_0">隐藏</button>
					</div>				
				</div>				
			</p>
		</li>
		<li class="deep">
			<p>
				<div class="container">
					<div id="answer_0" class="answer">（1）继承 Thread 类创建线程类<br>
（2）通过 Runnable 接口创建线程类<br>
（3）通过 Callable 和 Future 创建线程<br>
（4）通过线程池创建
					</div>
					<div>
						<button type="button" id="answer_btn_0">隐藏</button>
					</div>				
				</div>				
			</p>
		</li>
		<li>
			<p>
				<div class="container">
					<div id="question_1" class="question">创建线程的三种方式的对比</div>
					<div>
						<button type="button" id="question_btn_1">隐藏</button>
					</div>				
				</div>				
			</p>
		</li>
		<li class="deep">
			<p>
				<div class="container">
					<div id="answer_1" class="answer">
					Runnable、Callable 接口<br>
					可以继承其他类,多个线程共享同一个 target 对象,适合多个相同线程来处理同一份资源<br>
					代码和数据分开,清晰的模型,体现了面向对象的思想<br>
					Thread 类优势:<br>
					编写简单，直接使用 this即可获得当前线程<br>
					劣势是不能再继承其他父类
					
					</div>
					<div>
						<button type="button" id="answer_btn_1">隐藏</button>
					</div>				
				</div>				
			</p>
		</li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
	</ul>
	<p>
		<label id="my_label">count:</label>
	</p>
	<p>
		<button type="button" id="show_all_question_btn">显示所有问题</button>
		<button type="button" id="hide_all_question_btn">隐藏所有问题</button>
	</p>
	<p>
		<button type="button" id="show_all_answer_btn">显示所有答案</button>
		<button type="button" id="hide_all_answer_btn">隐藏所有答案</button>
	</p>
	
	
	
 
    <!-- 在这里编写你的JavaScript代码，它可以使用jQuery -->
    <script>
        $(document).ready(function(){
			var total_num = 0;
			$('.container').each(function(){
				total_num++;
			});
			$('#my_label').text("count:"+total_num);
			
			for(var i=0;i<total_num;i++){
				//console.log("in for ");
				 $('#question_btn_'+i).on("click",function(){
					var x = $(this).attr("id");	
					//console.log("this btn id = "+x);					
					var n = x.slice(x.lastIndexOf("_"),x.length);
					//console.log("this btn index = "+n);
					 if($('#question'+n).css("display")=="block"){						
						//console.log("in for click show ");
						$('#question_btn'+n).text("显示");
					 }else{
						//console.log("in for click hide ");						
						$('#question_btn'+n).text("隐藏");
					 }
					 
				 $('#question'+n).toggle();				 
				});
				 $('#answer_btn_'+i).on("click",function(){
					var x = $(this).attr("id");	
					//console.log("this btn id = "+x);					
					var n = x.slice(x.lastIndexOf("_"),x.length);
					//console.log("this btn index = "+n);
					 if($('#answer'+n).css("display")=="block"){						
						//console.log("in for click show ");
						$('#answer_btn'+n).text("显示");
					 }else{
						//console.log("in for click hide ");						
						$('#answer_btn'+n).text("隐藏");
					 }
					 
				 $('#answer'+n).toggle();				 
				});
				//console.log("in for ");
			}
            
			
			$('#show_all_question_btn').click(function(){
				$('.question').show();	
			});
			
			$('#hide_all_question_btn').click(function(){
				$('.question').hide();	
			});
			
			$('#show_all_answer_btn').click(function(){
				$('.answer').show();	
			});
			
			$('#hide_all_answer_btn').click(function(){
				$('.answer').hide();	
			});
        });
    </script>
	</body>
</html>